
import 'package:appflutter/Pages/Home/home_model.dart';
import 'package:appflutter/Pages/Home/home_movie_item.dart';
import 'package:appflutter/Pages/Home/home_request.dart';
import 'package:flutter/material.dart';

int _Count = 20;

class home_page extends StatefulWidget {
  @override
  _home_pageState createState() => _home_pageState();
}

class _home_pageState extends State<home_page> {

  int _start = 0;
  List<movie_item> movies = [];

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    home_request().get_home_movieItems(_start, _Count).then((reslut){//返回电影集合
      setState(() {
        movies.addAll(reslut);
      });
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('首页'),
      ),
      body: ListView.builder(
          itemBuilder: (BuildContext context,int index){

           final movie_item = movies[index];
           return home_movie_item(movie_item);

      },
      itemCount: movies.length,
      ),
    );
  }
}
